<%--
  Created by IntelliJ IDEA.
  User: 几何
  Date: 2022/4/17
  Time: 0:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>

<html>
<head>
    <title>Title</title>
</head>
<script type="text/javascript">
        var but =  $("#but");
        var id = $("#topicid").value();
        function a(){
        alert("A");
        $.ajax({
            url:"http://localhost:8081/ajaxuser/updateattention",
            data:{"userId":${id},"topicId":id},
            success:function(data){
                if(data){
                    but.value = "关注";
                }else{
                    but.value = "取消关注"
                }
            }
        })
    }

    function as(data){
            alert(data);
            alert("A");
    }
</script>
<body>
<h1>我的关注</h1>
<c:forEach var="item" items="${topics}">
    <a href="http://localhost:8081/userfunction/queryTopic?id=${item.topicId}">
        <div id="${item.topicId}">
        话题：<span>${item.topicName}</span>
        粉丝：<span>${item.topicAttention}</span>
        </div>
    </a>
        <input type="button" id="but" onclick="as(${id})" value="取消关注"><br/>

</c:forEach>
<input type="button" onclick="as(${id})" value="取消关注">

</body>
</html>
